home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3 / CHAPTE21 / EX2.C < prev    next >
C/C++ Source or Header  |  1995-10-29  |  2KB  |  43 lines

  1. #include <genstub.c>
  2.  
  3. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  4. {
  5.    switch (uMsg)
  6.    {
  7.          case WM_COMMAND:
  8.                switch ( LOWORD( wParam ) )
  9.                {
  10.                      case IDM_TEST:
  11.                      {
  12.                            LPTSTR lpTemp;
  13.                            char   szCommandLine[MAX_PATH + 1];
  14.                            char   szBuffer[MAX_COMPUTERNAME_LENGTH + 1];
  15.                            DWORD  dwcNameSize = MAX_COMPUTERNAME_LENGTH + 1;
  16.  
  17.                            // Report computer name.
  18.                            GetComputerName( szBuffer, &dwcNameSize );
  19.                            MessageBox( hWnd, szBuffer, "Computer Name", MB_OK );
  20.  
  21.                            // Parse first token from command line.
  22.                            lstrcpy( szCommandLine, GetCommandLine() );
  23.                            lpTemp = strstr( szCommandLine, " " );
  24.                            if ( lpTemp )
  25.                               lpTemp = strtok( lpTemp, " " );
  26.                            if  ( lpTemp )
  27.                               SetComputerName( lpTemp );
  28.                      }
  29.                      break;
  30.                      case IDM_EXIT:
  31.                            DestroyWindow( hWnd );
  32.                            break;
  33.                }
  34.                break;
  35.          case WM_DESTROY:
  36.                PostQuitMessage( 0 );
  37.                break;
  38.          default:
  39.                return (DefWindowProc(hWnd, uMsg, wParam, lParam));
  40.    }
  41.    return (NULL);
  42. }
  43.